package company.tencent;

import java.util.Scanner;

/**
 * @author briarbear
 * @blog https://briarbear.github.io
 * @date 2018-09-16 9:58
 */
public class T1 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();

            long[] dp1 = new long[10000000];
            dp1[1] = 1;
            for (int i = 2; i <= n+1; i++) {
                dp1[i] = minNum(dp1[i-1],i);
            }

            long[] dp2 = new long[1000000];
            dp2[0] = n + 1;
            for (int i = 1; i < 10000000; i++) {
                if (dp1[n+i] == dp2[i-1]){
                    System.out.println(i+n);
                    break;
                }
                dp1[n+i+1] = minNum(dp1[n+i],i+n+1);
                dp2[i] = minNum(dp2[i-1],i+n+1);

            }

        }
    }



    public static long minNum(long a,long b){
        long max,min,value = 1;
        if (a == b){
            return a;
        }

        max = Math.max(a,b);
        min  = Math.min(a,b);
        for (long i = 2; i <=  min; i++) {
            if ((max % i == 0)&&(min % i == 0)){
                value = i;
            }
        }

        return (min * max / value);
    }
}
